<?php
// +----------------------------------------------------------------------
// | 车钉钉 [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://www.twothink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: YagamiZN
// +----------------------------------------------------------------------

namespace app\home\controller;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class Index extends Home{
    /**
     * 前置操作方法列表
     * @var array $beforeActionList
     * @access protected
     */
    protected $beforeActionList = ['baseInfo'];
    /**
     * 构造方法，初始化站点信息
     */
    protected function _initialize(){
        //没有缓存查询mysql设置缓存
        if(!cache('baseMenu')&&!cache('baseWebMsg')){
            $this->baseMenu=db('base_menu')->where('isdisplay',1)->order('rank desc')->select();
            $this->baseWebMsg=db('base_webmsg')->select();
            $baseMenu=$this->baseMenu;
            $baseWebmsg=$this->baseWebMsg;
            cache('baseMenu', $baseMenu, 1);
            cache('baseWebMsg', $baseWebmsg, 1);
        }
        parent::_initialize();
    }
    //模版信息初始化
    public function baseInfo(){
        $baseMenu=cache('baseMenu');
        $baseWebmsg=cache('baseWebMsg');
        $this->assign('baseMenu',$baseMenu);
        $this->assign('baseWebMsg',$baseWebmsg);
        $request=  \think\Request::instance();
        $this->assign('controller',$request->controller());
        $this->assign('action',$request->action());
    }
	//网站首页
    public function index(){
        $brandList=db('car_brand')->where(['pid'=>0,'isdisplay'=>1])->order('rank','desc')->select();
        $this->assign('brandList',$brandList);
        return $this->fetch();
    }
    
    //网站服务
    public function service(){
        return $this->fetch();
    }
    
    //网站服务
    public function about(){
        return $this->fetch();
    }
    //常见问题
    public function questions(){
        return $this->fetch();
    }
    /* 空操作，用于输出404页面 */
    public function _empty(){
        $this->redirect('Index/index');
    }
}
